package com.citytransport.prokopjuk.builder_strategy;

import java.util.ArrayList;

import com.citytransport.prokopjuk.JSONparser.JSONParser;

import com.citytransport.prokopjuk.exception.InvalidFormatFile;
import com.citytransport.prokopjuk.vehicleDTO.*;


public class JSONRouteBuilder extends AbstractRouteBuilder {
	private JSONParser parser;
	private ArrayList<Vehicle> list;

	public JSONRouteBuilder(String fileURL) {
		parser = new JSONParser(fileURL);
		list = new ArrayList<Vehicle>();

	}

	@Override
	public void setIntervalMinute() {


	}

	@Override
	public void setRouteID() {
		
	}

	private void busConstract() {
		list.add(new Bus()
//		    (parser.parseInt("seatAmount"), parser
//					.parseString("registrationNumber"), parser
//					.parseBoolean("existCrippleDoor"), -1, 0, 0, null)
				);
	}

	private void tramConstract() {
		list.add(new Tram()
//				parser.parseInt("seatAmount"), parser
//					.parseString("registrationNumber"), parser
//					.parseBoolean("speedy"),-1)
		);
	}

	private void trollebusConstract() {
		list.add(new Trolleybus()
//				parser.parseInt("seatAmount"), parser
//					.parseString("registrationNumber"), parser
//					.parseInt("electricVolatge"),-1)
		);//tmp hack
	}

	public void constructList() {

		while (parser.hasNext()) {
			parser.next();
			try {
				if (parser.parseString("vehicleType").equalsIgnoreCase("Bus"))
					busConstract();

				if (parser.parseString("vehicleType").equalsIgnoreCase("Tram"))
					tramConstract();

				if (parser.parseString("vehicleType").equalsIgnoreCase(
						"Trollebus"))
					trollebusConstract();
			} catch (InvalidFormatFile e) {

				e.printStackTrace();
			}

		}

	}

	private ArrayList<Vehicle> getList() {
		constructList();
		return list;
	}

	@Override
	public void setVehicleOnRoute() {
		route.setVehicleOnRoute(getList());
	}

	@Override
	public void setPrice() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setStations() {
	    // TODO Auto-generated method stub
	    
	}

}
